<?php

function filter_int ($var) {
    return ! is_int($var);
}

$content = file_get_contents('pogoda.html');
/* 
$content = file_get_contents('http://pogoda.yandex.ru/orenburg/details/');
//*/

$pattern = '`<i title[^>]+>(?P<dn>[^<]+)</i>.*<b title[^>]+>(?P<md>[^<]+)</b><span>(?P<mn>[^<]+)</span>.*(?P<pdata>(<td class="dawn-dark"[^>]+>.*</td>)?<td class="t">.*<tr class="t-[^ ]+ last">.*</tr>)`Us';
if (preg_match_all($pattern, $content, $match)) {
    $keys = array_values(array_filter(array_keys($match), 'filter_int'));
    for ($i = 0; $i < count($match[0]); $i++) {
        
        foreach ($keys as $key) {
            if ($key == 'pdata') {
                
                $pattern = '`(<td class="dawn-dark"[^>]+><dl><dt>[^<]+</dt><dd>(?P<vos>[^<]+)</dd><dt>[^<]+</dt><dd>(?P<zak>[^<]+)</dd></dl><img src="[^"]+" alt="(?P<moon>[^"]+)"[^>]+></td>)?<td class="t"><strong>(?P<vrn>[^<]+)</strong><span>(?P<vrt>[^<]+)</span></td>.*<td class="data">(?P<vrpd>[^<]+)</td><td class="pressure">(?<vrpr>[^<]+)</td><td class="moisture">(?<vrmo>[^<]+)</td><td class="wind"><img src="[^"]+" title="[^:]+: (?P<vrnv>[^"]+)" alt="[^:]+: (?P<vrnvs>[^"]+)"[^>]+><span>(?P<vrvs>[^<]+)</span></td>`Us';
                
				if (preg_match_all($pattern, $match['pdata'][$i], $dmatch)) {
                    
					foreach ($dmatch as $k => $value){
						if (is_int($k)){
							unset($dmatch[$k]);
						} elseif (preg_match('/(vos|zak|moon)/',$k)) {
							$items[$i][$k] = $value[0];
							unset($dmatch[$k]);
						} elseif ($k == 'vrt') {
							// unicode convert
							$vrt = &$dmatch[$k];
							$vrt = str_replace('−','-',$vrt);
							$vrt = str_replace('…',' ',$vrt);
							foreach ($vrt as $vk => $vv) {
								$vrt[$vk] = explode(' ', $vv);
							}
						} elseif ($k == 'vrmo') {
							$dmatch[$k] = str_replace('%','',$dmatch[$k]);
						}
					}
					$items[$i][$key] = $dmatch;
                }
			} else {
				$items[$i][$key] = $match[$key][$i];
			}
        }
    }
    unset($match);
	foreach ($items as $item){
		var_dump($item);
	}
    
} else {
    echo "RE Error\n";
}

?>